package com.yin.add;

import com.sun.org.apache.bcel.internal.generic.ATHROW;

import java.util.concurrent.CountDownLatch;

// 计数器
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);

        for (int i = 0; i < 6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "  Go out!");
                countDownLatch.countDown();// 计数器 -1
            }, String.valueOf(i)).start();
        }
        countDownLatch.await(); // 计数器归零，然后向下执行

        System.out.println("关门！");

    }
}
